package com.opensource.datamodel.dto.page;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author wzh
 * @date 2024/5/9
 * @apiNote
 */
@Data
public class PageInfo implements Serializable {
//     curPage: 1,
//                pageSize: 0,
//                totalPage: 0,
//                totalRecord: 0
    private Integer curPage;
    private Integer pageSize;
    private Integer totalPage;
    private Integer totalRecord;

    public PageInfo(Integer curPage, Integer pageSize, Integer totalRecord) {
        this.curPage = curPage;
        this.pageSize = pageSize;
        this.totalRecord = totalRecord;
        //计算总页数
        if( this.totalRecord % this.pageSize  == 0 ){
            this.totalPage = this.totalRecord / this.pageSize;
        } else {
            this.totalPage = this.totalRecord / this.pageSize + 1;
        }
    }
}
